

/**
 * This item represents an item in a game with different effects
 * 
 * @author samkim
 *
 */
public class Item {
	private static final int MAX_DURABILITY = 100;
	private ItemType type;
	private int durability;
	
	public static enum ItemType {
		none, wire_cutters, binoculars, mine_detector, medicine, macbook_air, boots, k1, m16;
	}
	
	public Item(ItemType type) {
		this.type = type;
		durability = MAX_DURABILITY;
	}
	
	// Additional stats for random events needed
	
	public String toString() {
		return type.toString();
	}
	
	public boolean equals(Object o) {
		if (!(o instanceof Item))
			return false;
		Item i = (Item) o;
		return i.type == type;
	}

	public ItemType getType() {
		return type;
	}

	public boolean isWireCutters() {
		
		return type==ItemType.wire_cutters;
	}
	
	/**
	 * Damages this if it is wire cutters according to thickness of wires represented by input.
	 * @param thickness The thickness of the wire being cut. Should be less than 1.
	 * @return true if this broke, false otherwise.
	 */
	public boolean damage(double thickness) {
		durability -= (int) (((double)MAX_DURABILITY)*thickness);
		return durability<=0;
	}

	public int getDurability() {
		return durability;
	}
}
